package com.situ.dayTest;

import java.util.Scanner;

import org.junit.Test;

import com.situ.day11XianCheng.OuShu;

public class Xunhuan {
	/**
	 * 猜大小
	 */
	@Test
	public void test() { 
		int a = (int)(Math.random()* 100+1) ;
		System.out.println(a);
		Scanner scanner = new Scanner(System.in);
		while (true) {
			System.out.println("输入一个数");
			int shu  = scanner.nextInt();
			if (shu > a) {
				System.out.println("大了，继续猜");
			}else if (shu < a) {
				System.out.println("小了，继续猜");
			}else {
				System.out.println("恭喜");
				break;
			}
		}
	}
	/**
	 * 
	 */
	@Test
	public void test1() {
		for (int j = 1; j <= 3; j++) {
			for (int i = 1; i <= 4; i++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	/**
	 * 打印*
	 */
	
	@Test
	public void test2() {
		for (int j = 1; j <= 5; j++) {
			for (int i = 1; i <= j; i++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	
	/**
	 * 99乘法
	 */
	@Test
	public void test3() {
		for (int j = 1; j <= 9; j++) {
			for (int i = 1; i <= j; i++) {
				System.out.print(i + "*" + j + "=" + (i*j)+ "\t" );
			}
			System.out.println();
		}
	}
	/**
	 * 最大值
	 */
	@Test
	public void test4() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("输入第一个数： ");
		int one = scanner.nextInt();
		System.out.println("输入第二个数：");
		int two = scanner.nextInt();
		int max;
		if (one > two) {
			max = one;
		} else {
			max = two;
		}
		System.out.println("最大值：" + max);
	}
	/**
	 * 
	 */
	@Test
	public void test5() {
		for (int i = 1; i <= 5; i++) {
			for (int j = 1; j <= i; j++) {
				System.out.print(j);
			}
			System.out.println();
		}
	}
	
	@Test//正三角
	public void test6() {
		for (int i = 1; i <= 5; i++) {
			for (int j = 1; j <= 5-i; j++) {
				System.out.print("-");
			}
			for (int k = 1; k <= i*2-1; k++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	
	/**
	 * 倒三角
	 */
	@Test 
	public void test7(){
		for (int i = 0; i <= 6; i++) {
			for (int j = 1; j <=i; j++) {
				System.out.print(" ");
			}
			for (int k = 1; k <= 11-(i*2); k++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	
	@Test
	public void test8() {
		int ouShu = 0;
		int jiShu = 0;
		for (int i = 0; i <= 100; i++) {
			if (i % 2 == 0) {
				ouShu = ouShu + i; 
			}else {
				jiShu = jiShu + i;
			}
		}
		System.out.println("偶数：" + ouShu);
		System.out.println("奇数：" + jiShu);
	}
	
	@Test//5倍数
	public void test9() {
		int count = 0;
		for (int i = 0; i <= 100; i++) {
			if (i % 5 == 0) {
				count = count + 1;
				System.out.print(i + "\t");
			}
			if (count == 3) {
				System.out.println();
				count = 0;
			}
		}
	}
	
	
	@Test //9的阶数
	public void test10() {
		int sum = 1;
		for (int i = 9; i > 1 ; i--) {
			sum = sum * i;
		}
		System.out.println(sum);
	}
	
	@Test
	public void test11() {  
		for (int i = 100; i < 200; i++) {
			boolean suShu = true;
			for (int j = 2; j < i; j++) {  //内层循环一直无限跑
				if (i % j ==0) {
					suShu = false;
					break;
				}
			}
			if (suShu == true) {
				System.out.println(i);
			}
		}
		
	}
}
